import { XYZ } from "./XYZ";

export class OSM extends XYZ {
  constructor(opts?: { [key: string]: any }) {
    const options = opts || {};

    let attributions;
    if (options.attributions !== undefined) {
      attributions = options.attributions;
    } else {
      attributions = ['test'];
    }

    const crossOrigin =
      options.crossOrigin !== undefined ? options.crossOrigin : "anonymous";

    const url =
      options.url !== undefined
        ? options.url
        : "https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png";

    super({
      attributions: attributions,
      cacheSize: options.cacheSize,
      crossOrigin: crossOrigin,
      opaque: options.opaque !== undefined ? options.opaque : true,
      maxZoom: options.maxZoom !== undefined ? options.maxZoom : 19,
      reprojectionErrorThreshold: options.reprojectionErrorThreshold,
      tileLoadFunction: options.tileLoadFunction,
      url: url,
      wrapX: options.wrapX,
    });
  }
}
